<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/store/include/init_store.jsp" %>
<%

	if (!isSeller) {
		response.sendRedirect("/publisher");
		return ;
	}


	HashList code015	= CommonUtil.getCodeList("015");	//판매자구분
	HashList code016	= CommonUtil.getCodeList("016");	//은행
	HashList code019	= CommonUtil.getCodeList("019", "전체");		//OS
	HashList code018	= CommonUtil.getCodeList("018", "전체");		//스토어
	HashList code020	= CommonUtil.getCodeList("020", "전체");		//결재방법
	

	String s_sales_dt_from	= StringUtil.nvl(request.getParameter("s_sales_dt_from"), TODAY.substring(0,6)+"01");
	String s_sales_dt_to	= StringUtil.nvl(request.getParameter("s_sales_dt_to"), TODAY);
	String s_store_code		= StringUtil.nvl(request.getParameter("s_store_code"));
	String s_pay_method		= StringUtil.nvl(request.getParameter("s_pay_method"));
	
	HashMap infos = new HashMap();
	infos.put("publisher_id", session_user_id);
	infos.put("sales_dt_from", s_sales_dt_from);
	infos.put("sales_dt_to", s_sales_dt_to);
	infos.put("pay_method", s_pay_method);
	
	PublisherDAO dao = new PublisherDAO();
	HashList list 	= dao.selectSalesList(infos);
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= HOME_NAME %></title>
	<%@ include file="/home/include/cssnjs.jsp"  %>
	<link rel="stylesheet" type="text/css" href="../../css/smoothness/jquery-ui-1.8.17.custom.css" media="screen" />
	<script type="text/javascript" src="../../js/jquery-ui-1.8.18.custom.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../js/jquery.maskedinput-1.3.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../js/jquery.ui.datepicker-ko.js" charset="utf-8"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#store_main li:nth-child(1)').addClass('on');
		$('#s_sales_dt_from').mask('9999.99.99').datepicker();
		$('#s_sales_dt_to').mask('9999.99.99').datepicker();
	});
	
	function fnSubmit() {
		document.searchForm.submit();
	}

	</script>
</head>
<body>
	<div id="wrap">
		<%@ include file="/publisher/include/header.jsp"  %>
		
		<div id="contents">
			<h2>판매내역</h2>
			<form name="searchForm" id="searchForm" method="post" action="./salesList.jsp">

			<table cellpadding="0" cellspacing="0" class="table_01 mt15">
			<colgroup>
				<col width="100px" />
				<col width="240px" />
				<col width="100px" />
				<col width="160px" />
				<col width="100px" />
				<col  />
			</colgroup>
			<tr>
			    <th><p>판매일자</p></th>
			    <td>
			    	<input type="text" name="s_sales_dt_from" id="s_sales_dt_from" value="<%= s_sales_dt_from %>" class="w80"/>
			    	~
			    	<input type="text" name="s_sales_dt_to" id="s_sales_dt_to" value="<%= s_sales_dt_to %>" class="w80"/>
			    </td>
				<th><p>스토어</p></th>
				<td>
					<select name="s_store_code" class="w100">
					<%= StringUtil.makeOption(code018, s_store_code) %>
					</select>
				</td>
				<th><p>결재방법</p></th>
				<td class="brx">
					<select name="s_pay_method" class="w100">
					<%= StringUtil.makeOption(code020, s_pay_method) %>
					</select>
				</td>
			</tr>
			</table>
 
			<div class="mt10 mb10 r">
				<a href="#nohref" onclick="fnSubmit()"><img src="./images/btn_search.gif"/></a>
				<!-- <button id="login_btn" class="btn" title="조회">조회</button> -->
			</div>

			</form>

		<div class="search_result">검색결과 : <%=list.size() %>건</div>

	    <table cellpadding="0" cellspacing="0" class="table_01">
			<colgroup>
				<col width="100px"/>
				<col/>
				<col width="100px"/>
				<col width="100px"/>
				<col width="80px"/>
				<col width="80px"/>
				<col width="80px"/>
			</colgroup>
			<thead>
				<tr>
					<th><p>판매일자</p></th>
					<th><p>큐북명</p></th>
					<th><p>스토어</p></th>
					<th><p>결재방법</p></th>
					<th><p>판매금액</p></th>
					<th><p>수수료</p></th>
					<th><p>수익</p></th>
				</tr>
			</thead>
			<tbody id="list">
			<%	for (int i = 0; i < list.size(); i++) { %>
				<tr>
					<td class="c"><%= StringUtil.toDate(list.get("sales_dt",i)) %></td>
					<td><%= list.get("book_name",i) %></td>
					<td class="c"><%= list.get("store_name",i) %></td>
					<td class="c"><%= list.get("pay_method",i) %></td>
					<td class="r"><%= list.getPrice("price",i) %></td>
					<td class="r"><%= list.getInt("price",i) - list.getInt("sales_amount",i) %></td>
					<td class="r"><%= list.getPrice("sales_amount",i) %></td>
				</tr>
			<%	} %>
			<%	if (list.size() == 0) { %>
				<tr>
					<td class="no_result" colspan="7">검색된 결과가 없습니다.</td>
				</tr>
			<%	} %>
			</tbody>
		</table>
			
             
		</div>
		
		<%@ include file="/publisher/include/footer.jsp"  %>		
	</div>

</body>



</html>
